import { MockMethod } from "vite-plugin-mock";
import Mock from "mockjs";
export default [
  {
    url: "/api/getList",
    method: "post",
    timeout: 1000,
    response: ({ body }: { body: any }) => {
      // 对传入的参数做校验逻辑（待补充）
      console.log(body);
      /**
       * 模拟数据：模拟生成随机颜色
       */
      const a = "#" + Mock.Random.integer(180, 255).toString(16) + Mock.Random.integer(140, 255).toString(16) + Mock.Random.integer(120, 220).toString(16);
      //返回数据
      return {
        code: 200,
        message: "ok",
        "data|5": [
          {
            imageLine: `@image('400x400',${a}, '#FFF', 'Mock.js')`,
            nickname: "@cname",
            "age|18-50": 18,
            "id|+1": 0,
            url: "@image",
            date: "@date(yyyy-MM-dd)",
            description: "@paragraph",
          },
        ],
      };
    },
  },
] as MockMethod[];
